﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection.Emit;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Eremex.AvaloniaUI.Controls.License;
namespace QIDE
{

	public class QControlsLicenseManager : ControlsLicenseManager
	{

	}
	public class RoslynHelper
	{
		public static void Crack()
		{
			Type thirdPartyType = typeof(ControlsLicenseManager);
			MethodInfo originalMethod = thirdPartyType.GetMethod("ValidateSetRuntimeLicenseKey", BindingFlags.Public | BindingFlags.Static);

			// 创建一个动态方法来替代原始方法
			DynamicMethod dynamicMethod = new DynamicMethod(
				originalMethod.Name,
				typeof(bool), // 返回类型
				Type.EmptyTypes, // 参数类型
				thirdPartyType.Module);

			ILGenerator il = dynamicMethod.GetILGenerator();
			il.Emit(OpCodes.Ldc_I4_1); // 加载 true
			il.Emit(OpCodes.Ret); // 返回

			// 替换原始方法
			var newMethod = dynamicMethod.CreateDelegate(originalMethod.DeclaringType);
		}
	}
}
